<?php

//就近 www.jiujin.me
global $_W, $_GPC;
$openid = m('user')->getOpenid();
$mem = m('member')->getMember($openid);
$agentid = $mem['id'];
if ($_W['isajax']) {
	$member = $this->model->getInfo($openid, array('total', 'ordercount0', 'ok'));
	$cansettle = $member['commission_ok'] > 0 && $member['commission_ok'] >= floatval($this->set['withdraw']);
	$commission_ok = $member['commission_ok'];
	$member['agentcount'] = number_format($member['agentcount'], 0);
	$member['ordercount0'] = number_format($member['ordercount0'], 0);
	$member['commission_ok'] = number_format($member['commission_ok'], 2);
	$member['commission_pay'] = number_format($member['commission_pay'], 2);
	$member['commission_total'] = number_format($member['commission_total'], 2);
	
	/*
	 *  gmm
	 *  功能：上级分销人
	 *  时间：2015年11月24日
	 */
	if($member['agentid']){
		$shangji = pdo_fetch('select nickname from ' . tablename('ewei_shop_member') . " where uniacid=:uniacid AND id =:id", array(':uniacid' => $_W['uniacid'],':id'=>$member['agentid']));
		$member['shangji'] = $shangji['nickname'];
	}
	
	if (mb_strlen($member['nickname'], 'utf-8') > 6) {
		$member['nickname'] = mb_substr($member['nickname'], 0, 6, 'utf-8');
	}
	$openselect = false;
	if ($this->set['select_goods'] == '1') {
		if (empty($member['agentselectgoods']) || $member['agentselectgoods'] == 2) {
			$openselect = true;
		}
	} else {
		if ($member['agentselectgoods'] == 2) {
			$openselect = true;
		}
	}
	$this->set['openselect'] = $openselect;
	$level = $this->model->getLevel($openid);
	show_json(1, array('commission_ok' => $commission_ok, 'member' => $member, 'level' => $level, 'cansettle' => $cansettle, 'settlemoney' => number_format(floatval($this->set['withdraw']), 2), 'set' => $this->set));
}
//gmm 2015-12-21 大伙伴审核人数小圆点
if($mem['agentlevel'] == 1 || $mem['agentlevel'] == 2){		//战略或大伙伴
	$confirm_num = pdo_fetchcolumn('select count(*) from ' . tablename('ewei_shop_member') . " where uniacid = :uniacid and zhaomu = 1 and status = 0 and isagent = 1 and agentid = :agentid ",
			array(':uniacid' => $_W['uniacid'], ':agentid' => $mem['id']));
}else{
	$confirm_num = 0;
}

include $this->template('index');